package com.lzy.interceptor;

import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Controller;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

/**
 * @autor shkstart
 * @create 2021-01-05 21:47)
 */
@Configuration
public class WebConfig implements WebMvcConfigurer {
    //给WebMVC填加过滤器
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new LoginInterceptor())
                .addPathPatterns("/admin/**")  //拦截/admin下所有请求
                .excludePathPatterns("/admin","/admin/login"); //不拦截登录页面，登录请求
    }
}
